﻿namespace TanzimSaqib.NoBrainer.Sample.Account
{
    using System.Web.Security;
    using DataAccess;
    using System;
    using Controllers;

    public partial class CreatePost : ViewBase<PostController, Post>
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                Model.UserId = (Guid)Membership.GetUser().ProviderUserKey;
                Model.Created = DateTime.Now;
                InvokeController(v => Controller.Create(Model));

                if (Model.IsValid)
                    Response.Redirect("~/Account/Manage.aspx?Status=Added");
            }
            else 
                // Example: how you can set default values on Page Load.
                InvokeController(v => Controller.CreatePostLoad(Model));
        }
    }
}